<?php

namespace Controller\Ajax;

class Base extends \Lib\Core\Ajax {

    /**
     * 未登录错误代码
     */
    const AJAX_ERROR_NO_LOGIN = 300;

    /**
     * 当前登录的用户信息.
     *
     * @var array
     */
    public $currentUserInfo;

    public function actionBefore() {
		$mask = $this->getUserMask();
		$this->currentUserInfo = \Business\User::instance()->getCurrentUserInfo($mask);
    }

    protected function mustLogin() {
        if (!$this->currentUserInfo) {
            $this->responseError('请登录', \Entity\ErrorCode::USER_NO_LOGIN);
        }
    }
}